<?php
/**
 * Created by PhpStorm.
 * User: Cloud
 * Date: 2018/5/14
 * Time: 13:23
 */
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->
    <meta charset="UTF-8">
    <title>详细统计</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="author" content="evil_web（429391294@qq.com）"/>
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/popup.css"/>
    <link rel="stylesheet" href="public/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="public/css/bootstrap.css">
    <link rel="stylesheet" href="public/css/dcalendar.picker.css">
    <link rel="stylesheet" href="public/css/paging.css">
    <link rel="stylesheet" href="public/css/paging.css">
    <link rel="stylesheet" href="public/css/cqs.style.css">
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->

    <style type="text/css">
        * {
            box-sizing: unset;
        }

        dt, dd {
            line-height: unset;
        }
    </style>

</head>
<body style="background-color: #f4f4f4;">
<?php $this->load->view('common/header.php'); ?>

<div class="cqs-main">
    <form method="get">
        <div class="cqs-main_top cqs-mgt30">
            数据报表：<a class="cqs-clc40000" href="javascript:;">成本中心＞</a>

            <div class="date-box">
                <!--            // --><?php //if ( isset($ymd)):?><!--  value="-->
                <?php //echo $ymd ;?><!--"  --><?php //endif;?>
                <span class="date-group"><input id='mydatepicker'
                                                name="mydatepicker" <?php if (isset($ymd)): ?> placeholder="<?php echo $ymd; ?>"  <?php endif; ?>
                                                type='text'/>
        <img src="img/btn_arrow_down_h.png" alt=""></span> —
                <span class="date-group">
                <input id='mydatepicker2' <?php if (isset($ymd2)): ?> placeholder="<?php echo $ymd2; ?>"  <?php endif; ?>
                       type='text' value=""/>
                <input type="hidden" name="mydatepicker2" class="mydatepicker2" type='text' value=""/>
        <img src="img/btn_arrow_down_h.png" alt=""></span>
            </div>

            <div class="cqs-search-group"><span class="cqs-img-search">
                <img src="img/icon_search_grey.png" alt=""></span>
                <input type="text" id="username" name="username"
                       placeholder="在当前条件下搜索账户" <?php if (isset($username)): ?> value="<?php echo $username; ?>"  <?php endif; ?>>
                <!--            <input type="hidden" name="admin" value="--><?php //if(isset($_GET['admin'])):?><!---->
                <? //=$_GET['admin']?><!----><?php //endif;?><!--">-->
                <!--            <input type="hidden" name="account" value="-->
                <?php //if(isset($_GET['account'])):?><!----><? //=$_GET['account']?><!----><?php //endif;?><!--">-->
                <!--            <input type="hidden" name="user" value="--><?php //if(isset($_GET['user'])):?><!---->
                <? //=$_GET['user']?><!----><?php //endif;?><!--">-->
                <!--            <input type="hidden" name="mydatepicker" value="-->
                <?php //if(isset($_GET['mydatepicker'])):?><!----><? //=$_GET['mydatepicker']?><!---->
                <?php //endif;?><!--">-->
                <!--            <input type="hidden" name="mydatepicker2" value="-->
                <?php //if(isset($_GET['mydatepicker2'])):?><!----><? //=$_GET['mydatepicker2']?><!---->
                <?php //endif;?><!--">-->
            </div>
            <div class="checkbox-group" style="margin-left: 10px;"><input type="checkbox" name="admin"
                                                                          id="admin" <?php if (isset($admin) && $admin == 1): ?>  value="1" checked   <?php endif; ?>><label
                        for="admin">admin</label>
            </div>

            <div class="checkbox-group"><label for="account"><input type="checkbox" name="account"
                                                                    id="account" <?php if (isset($account) && $account == 2): ?> value="2" checked   <?php endif; ?> >管理账户</label>
            </div>
            <div class="checkbox-group"><label for="user"><input type="checkbox" name="user"
                                                                 id="user" <?php if (isset($user) && $user == 3): ?> value="3" checked   <?php endif; ?> >用户账号</label>
            </div>
            <button class="cqs-output">导出报表</button>
        </div>
    </form>
    <div class="cqs-main_con table-responsive cqs-box cqs-mgb50 cqs-bgfff"><!--table table-bordered -->
        <table class="table table-bordered cqs-table">
            <tr>
                <th>序号</th>
                <th>账号</th>
                <th>所属成本中心</th>
                <?php if (isset($time6)): ?>
                    <th><?php echo $time6 ?></th>
                <?php endif; ?>
                <?php if (isset($time5)): ?>
                    <th><?php echo $time5 ?></th>
                <?php endif; ?>
                <?php if (isset($time4)): ?>
                    <th><?php echo $time4 ?></th>
                <?php endif; ?>
                <?php if (isset($time3)): ?>
                    <th><?php echo $time3 ?></th>
                <?php endif; ?>
                <?php if (isset($time2)): ?>
                    <th><?php echo $time2 ?></th>
                <?php endif; ?>

                <?php if (isset($times)): ?>
                    <th><?php echo $times ?></th>
                <?php endif; ?>
                <th>合计(元)</th>
            </tr>
            <tbody>
            <!--            --><?php //if (isset($orders) && count($orders)):?>
            <!--            --><?php //foreach($orders as $key=>$or):?>
            <!--       --><?php ////if (count($or['money6']) ||count($or['money5']) ||count($or['money4']) ||count($or['money3'])|| count($or['money2']) || count($or['money1'])):?>
            <!--            <tr class="attr">-->
            <!--                <td>--><?php //echo $key+1?><!--</td>-->
            <!--                <td>--><?php //echo $or['username']?><!--</td>-->
            <!--                <td>--><?php //echo $or['name']?><!--</td>-->

            <!--             <?php //if (count($or['money6'])):?>
<!--                    <td><?php //echo count($or['money6'])?></td>
<!--                --><?php //else:?>
            <!--                    <td>0</td>-->
            <!--                --><?php //endif;?>
            <!---->
            <!--                --><?php //if (count($or['money5'])):?>
            <!--                    <td>--><?php //echo count($or['money5'])?><!--</td>-->
            <!--                --><?php //else:?>
            <!--                    <td>0</td>-->
            <!--                --><?php //endif;?>
            <!--                --><?php //if (count($or['money4'])):?>
            <!--                    <td>--><?php //echo count($or['money4'])?><!--</td>-->
            <!--                --><?php //else:?>
            <!--                    <td>0</td>-->
            <!--                --><?php //endif;?>
            <!--                --><?php //if (count($or['money3'])):?>
            <!--                    <td>--><?php //echo count($or['money3'])?><!--</td>-->
            <!--                --><?php //else:?>
            <!--                    <td>0</td>-->
            <!--                --><?php //endif;?>
            <!--                --><?php //if (count($or['money2'])):?>
            <!--                    <td>--><?php //echo count($or['money2'])?><!--</td>-->
            <!--                --><?php //else:?>
            <!--                    <td>0</td>-->
            <!--                --><?php //endif;?>
            <!--                --><?php //if (count($or['money1'])):?>
            <!--                <td> --><?php //echo count($or['money1'])?><!-- </td>-->
            <!--                --><?php //else:?>
            <!--                    <td>0</td>-->
            <!--                --><?php //endif;?>
            <!--<!--count($or['money1']):0-->
            <!--<!--            isset($or['money2'])?count($or['money2']):0 +-->
            <!--                <td>--><?php //echo  isset($or['money1'])?count($or['money1']):0?><!--</td>-->
            <!--            </tr>-->

            <!--                --><?php ////endif;?>
            <!--            --><?php //endforeach;?>
            <!--            --><?php //endif;?>
            </tbody>
        </table>

        <div class="box" id="box"></div>
    </div>
</div>
<?php $this->load->view('common/bottom.php'); ?>

<script src="public/js/jquery.min.js"></script>
<script src="public/js/bootstrap-table.min.js"></script>
<script src="public/js/paging.min.js"></script>
<script src="public/js/dcalendar.picker.js"></script>

<script>
    var setTotalCount = 301;
    $('#box').paging({
        initPageNo: 1, // 初始页码
        totalPages: <?php echo ceil(count($orders) / 10) ?>, //总页数
        totalCount: '', // 条目总数
        slideSpeed: 600, // 缓动速度。单位毫秒
        jump: true, //是否支持跳转
        callback: function (page) { // 回调函数
            // console.log(page);
            var admin = $('#admin').val();
            var account = $('#account').val();
            var user = $('#user').val();
            var username = $('#username').val();
            var ymd = $('#mydatepicker').attr('placeholder');
            var ymd2 = $('#mydatepicker2').attr('placeholder');
            console.log(ymd2);
            console.log(ymd);
            //location.href="<?php //echo base_url()?>//information/information_purchase_user?page="+page;
            $.ajax({
                type: "post",
                url: "information/information_purchase_user",
                data: {
                    page: page,
                    admin: admin,
                    account: account,
                    user: user,
                    ymd: ymd,
                    ymd2: ymd2,
                    username: username
                },
                dataType: "json",
                async: true,
                success: function (data) {
                    var html = "";
                    // console.log(data);
                    $(data.data).each(function (key, val) {
                        // console.log(val);
                        html += "  <tr class='attr'>";

                        html += "  <td>" + (key + 1) + "</td>";

                        html += "  <td>" + val.username + "</td>";
                        html += "  <td>" + val.name + "</td>";
                        if (!val.money6) {
                            html += "  <td>0</td>";
                        } else {
                            html += "  <td>" + val.money6 + "</td>";
                        }
                        if (!val.money5) {
                            html += "  <td>0</td>";
                        } else {

                            html += "  <td>" + val.money5 + "</td>";
                        }

                        if (!val.money4) {
                            html += "  <td>0</td>";
                        } else {
                            html += "  <td>" + val.money4 + "</td>";

                        }
                        if (!val.money3) {
                            html += "  <td>0</td>";
                        } else {
                            html += "  <td>" + val.money3 + "</td>";

                        }
                        if (!val.money2) {
                            html += "  <td>0</td>";
                        } else {

                            html += "  <td>" + val.money2 + "</td>";
                        }
                        if (!val.money1) {
                            html += "  <td>0</td>";
                        } else {
                            html += "  <td>" + val.money1 + "</td>";
                        }
                        if (!val.moneys) {
                            html += "  <td>0</td>";
                        } else {
                            html += "  <td>" + val.moneys + "</td>";
                        }

                        html += " </tr>";
                    });
                    $(".table tbody:last").html(html);
                    // console.log(html);
                }
            });

        }
    });

    var _date = new Date();
    // console.log( format);
    $('#mydatepicker').dcalendarpicker({
        format: 'yyyy-MM-dd',
        defaultDate: '2',
        changeYear: true
    });
    $('#mydatepicker2').dcalendarpicker({
        format: 'yyyy-MM-dd',
        defaultDate: _date
    });
</script>
<script type="text/javascript">
    $('#admin').click(function () {
        // console.log(4545);
        // $('#admin').attr('checked','chencked');
        // var mydatepicker=$('#mydatepicker').val();
        // var mydatepicker2=$('#mydatepicker2').val();
        console.log(mydatepicker);
        console.log(mydatepicker2);
        var admins = $('#admin').attr('checked');
        if (admins) {
            $('#admin').val('1');
        } else {
            $('#admin').val("");
        }
        var accounts = $('#account').attr('checked');
        if (accounts) {
            $('#account').val('2');
        } else {
            $('#account').val("");
        }
        var users = $('#user').attr('checked');
        if (users) {
            $('#user').val('3');
        } else {
            $('#user').val("");
        }
        var admin = $('#admin').val();
        var account = $('#account').val();
        var user = $('#user').val();
        location.replace("<?php echo base_url()?>information/information_purchase_user?admin=" + admin + "&account=" + account + "&user=" + user);

    });
    $('#account').click(function () {
        var admins = $('#admin').attr('checked');
        if (admins) {
            $('#admin').val('1');
        } else {
            $('#admin').val("");
        }
        var accounts = $('#account').attr('checked');
        if (accounts) {
            $('#account').val('2');
        } else {
            $('#account').val("");
        }
        var users = $('#user').attr('checked');
        if (users) {
            $('#user').val('3');
        } else {
            $('#user').val("");
        }
        var admin = $('#admin').val();
        var account = $('#account').val();
        var user = $('#user').val();
        location.replace("<?php echo base_url()?>information/information_purchase_user?admin=" + admin + "&account=" + account + "&user=" + user);
    });
    $('#user').click(function () {
        var admins = $('#admin').attr('checked');
        if (admins) {
            $('#admin').val('1');
        } else {
            $('#admin').val("");
        }
        var accounts = $('#account').attr('checked');
        if (accounts) {
            $('#account').val('2');
        } else {
            $('#account').val("");
        }
        var users = $('#user').attr('checked');
        if (users) {
            $('#user').val('3');
        } else {
            $('#user').val("");
        }
        var admin = $('#admin').val();
        var account = $('#account').val();
        var user = $('#user').val();
        location.replace("<?php echo base_url()?>information/information_purchase_user?admin=" + admin + "&account=" + account + "&user=" + user);
    });
    // $('#mydatepicker').click({
    //     console.log(6)
    // })
    $('.calendar').on('click', function () {
        var myd = $('#mydatepicker').val(),
            myd2 = $('#mydatepicker2').val();
        $('#mydatepicker').attr('placeholder', myd);
        $('.mydatepicker2').val(myd);
        $('#mydatepicker2').attr('placeholder', myd2);
        var admin = $('#admin').val();
        var account = $('#account').val();
        var user = $('#user').val();
        console.log($('#mydatepicker').val());
        console.log($('#mydatepicker2').val());
        // window.location.search = jQuery.query.set("myd", myd).set("myd2", myd2);
        //location.replace("<?php //echo base_url()?>//information/information_purchase_user?ymd="+myd+"&ymd2="+myd2+"&admin="+admin+"&account="+account+"&user="+user);
    })
</script>
</body>
</html>

